package com.hhxy.practice;

import java.util.Scanner;
//加密数字
public class EncryptNumber {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你要加密的数字长度");
        int length = sc.nextInt();
        System.out.println("请输入你想加密的数字,以#结束");
        int[] arr = new int[length];
        for (int i = 0; !sc.hasNext("#"); i++) {
            arr[i] = sc.nextInt();
        }
        encryptNumber(arr);
        System.out.println("加密后的数字为：");
        for (int i = 0; i <length ; i++) {
            System.out.print(arr[i]);
        }
    }
    //加密数字：每位数都加上5 , 再对10求余，最后将所有数字反转
    private static void encryptNumber(int[] arr) {
        int t;
        for (int i = 0; i <arr.length/2 ; i++) {//i是“<”，所以除以2不要再减一
            t = arr[i];
            arr[i] = (arr[arr.length-i-1]+5)%10;
            arr[arr.length-i-1] = (t+5)%10;
        }
    }

}
